package com.woniu.api;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.woniu.dto.DrugsDto;
import com.woniu.dto.DrugsPageDto;
import com.woniu.param.DeleteDrugsByListIdParam;
import com.woniu.param.DrugsParam;
import com.woniu.param.QueryDrugsPageParam;
import com.woniu.util.Result;
import io.swagger.annotations.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;

@FeignClient( value = "drugs",
        contextId = "drugs",
        path = "/drugs")

@Api(tags="药品服务接口")
public interface DrugsApi {

    @PostMapping("/getMedicineName")
    @ApiOperation("根据药品名字进行搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "medicineName",
                    value = "药品名称",
                    required = false,
                    dataType = "string" )
                    })

    @NotNull(message = "名称不能为空")
    Result<DrugsPageDto> getDrugs(@RequestBody QueryDrugsPageParam queryDrugsPageParam) throws JsonProcessingException;



    @ApiOperation("根据药品id进行搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "medicineId",
                    value = "药品id",
                    required = false,
                    dataType = "integer" )
    })
    @GetMapping("/getMedicineNameById")
    Result<DrugsDto> getDrugsById(@RequestParam("medicineId")  Integer medicineId);


    @ApiOperation("新增药品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "drugsParam",
                    value = "药品",
                    required = false,
                    dataType = "DrugsParam" )
    })
    @PostMapping("/addDrugs")

    Result<DrugsDto> addDrugs(@RequestBody DrugsParam drugsParam);

    @DeleteMapping("/deleteDrugs")
    @ApiOperation("根据药品id进行删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "medicineIdlist",
                    value = "药品id list",
                    required = false,
                    dataType = "list" )
    })
    Result<?>DeleteDrugs(@RequestBody DeleteDrugsByListIdParam deleteDrugsParamByListId);

    @PostMapping("/updateDrugs")
    @ApiOperation("根据药品进行修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "drugsParam",
                    value = "药品",
                    required = false,
                    dataType = "DrugsParam")
    })
    Result<DrugsDto> updateDrugs(@RequestBody DrugsParam drugsParam);
}
